package sk.isomi.jcf;

import java.util.AbstractMap.SimpleEntry;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.TreeMap;

import sk.isomi.minihr.entities.Employee;

public class MapImpl {

	/**
	 * @param args
	 * @throws Exception 
	 */
	public static void main(String[] args) throws Exception {
		testMap();
	}

	@SuppressWarnings("unchecked")
	public static void testMap() throws Exception {
		Map<String, Employee> mapEmplByIdHM = new HashMap<String, Employee>();
		Map<String, Employee> mapEmplByIdTM = new TreeMap<String, Employee>();
		
		// init 		
		Employee empl1 = new Employee("E13", "Skulavik", "111111/1111", "jan.skulavik@openit.sk");
		Employee empl2 = new Employee("E12", "Kubicek",  "222222/2222", "jaro.kubicek@openit.sk");
		Employee empl3 = new Employee("E11", "Skulavik", "111111/1111", "jan.skulavik@openit.sk");
			
		mapEmplByIdHM.put(empl1.getId(), empl1);
		mapEmplByIdHM.put(empl2.getId(), empl2);
		mapEmplByIdHM.put(empl3.getId(), empl3);
		
		Employee testEmpl = mapEmplByIdHM.get("E12");
		System.out.println(testEmpl);
		
		System.out.println("HM " + mapEmplByIdHM.size());
		for (Employee employee : mapEmplByIdHM.values()) {
			System.out.println(employee);
		}
		
		for (String key : mapEmplByIdHM.keySet()) {
			System.out.println(key);
		}

		
		mapEmplByIdTM.put(empl1.getId(), empl1);
		mapEmplByIdTM.put(empl2.getId(), empl2);
		mapEmplByIdTM.put(empl3.getId(), empl3);

		Object[] obj = mapEmplByIdHM.entrySet().toArray();
		
		Entry<String, Employee> keyValuePair;
		for (Object object : obj) {
			keyValuePair = (Entry<String, Employee>)object;
			object.getClass().getGenericSuperclass();
			System.out.println("Key: " + keyValuePair.getKey());
			System.out.println("Value: " + keyValuePair.getValue());
		}
		
		
		System.out.println("TM " + mapEmplByIdTM.size());
		for (Employee employee : mapEmplByIdTM.values()) {
			System.out.println(employee);
		}
		
		for (String key : mapEmplByIdTM.keySet()) {
			System.out.println(key);
		}
	
	
	
	}

}
